package me.mysort;

public class A04_RecursionDemo1 {
    public static void main(String[] args) {
        //递归练习1：求1~100之间的和
        //练习2：求5的阶乘
        //递归核心：找出口和找规律
        System.out.println(getSum(100));
        System.out.println(getFactorialRecursion(5));
    }

    public static int getSum(int number) {
        //出口
        if (number == 1) {
            return 1;
        }
        return number + getSum(number - 1);
    }

    public static int getFactorialRecursion(int number) {
        if (number == 1) {
            return 1;
        }
        return number * getFactorialRecursion(number - 1);
    }

}
